//
//  UIImageVIew+WebImage.swift
//  微博
//
//  Created by 康智桐 on 2018/5/2.
//  Copyright © 2018年 Kk. All rights reserved.
//

import SDWebImage

extension UIImageView {
    
    func cz_setImage(urlString:String?,placeholderImage:UIImage?,isAvatar:Bool = false){
        
        
        guard let urlString = urlString,let url = URL(string:urlString) else {
          image = placeholderImage
            return
        }
        
        
        sd_setImage(with: url, placeholderImage: placeholderImage, options: [], progress: nil) {
           [weak self] ( image, _, _, _)in
            
            if isAvatar{
                self?.image = image?.cz_avatarImage(size: self?.bounds.size)
            }
        }
        
    }
    
    
    
    
    
}
